package com.anrongtec.zcpt.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.anrongtec.zcpt.ApiConfig;
import com.anrongtec.zcpt.JWTApp;


public class PrefUtils {

    private static final String PREF_NAME = "kunlun-pref";
    public static final String KEY_VERSION_CODE = "versionCode";
    private static final String KEY_GUIDE_ACTIVITY = "guide_activity";


    public static SharedPreferences getPref() {
        return JWTApp.getInstance().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    }


    public static String getMUserName() {

        return getPref().getString(KEY_GUIDE_ACTIVITY, "");
    }

    public static void setMUsername(String state) {
        getPref().edit().putString(KEY_GUIDE_ACTIVITY, state).commit();
    }

    /**
     * 是否是当前版本第一次启动
     *
     * @return boolean
     */
    public static boolean isVirgin() {
        if (getVersionCode().equals(ApiConfig.BaseInfo.APP_VERSION)) {
            return false;
        }
        return true;
    }

    public static String getVersionCode() {
        return getPref().getString(KEY_VERSION_CODE, "");
    }

    public static void setVersionCode(String versionCode) {
        getPref().edit().putString(KEY_VERSION_CODE, versionCode).commit();
    }

}
